# writer:sp
# tiem: 2024/8/15 11:22
import datetime

def log_login(func):
    def wrapper(username, password):
        print(f"[{datetime.datetime.now()}] User '{username}' is attempting to log in.")
        result = func(username, password)
        if result:
            print(f"[{datetime.datetime.now()}] User '{username}' has logged in successfully.")
        else:
            print(f"[{datetime.datetime.now()}] Login failed for user '{username}'.")
        return result
    return wrapper

@log_login
def login(username, password):
    # 假设这是一个简单的登录检查
    if username == "admin" and password == "secret":
        return True
    return False

# 调用 login 函数
if login("admin", "secret"):
    print("Login successful!")
else:
    print("Login failed.")
